using System;
using System.Collections.Generic;
using System.Text;
using ECommerce.DAL;
using System.Data.SqlClient;
using System.Data;

namespace Entity
{
    [System.ComponentModel.DataObject]
    public class TblShipmentCostExtended : TblShipmentCost
    {
        public static CustomCollection<TblShipmentCost> GetNonDeletedShipmentCostPaged(string orderBy, int startRow, int pageSize)
        {
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_SHIPMENTCOST_GET_NONDELETED_SHIPMENTCOST_PAGED);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblShipmentCostCollectionFromReader);
            CustomCollection<TblShipmentCost> objCollection = ((CustomCollection<TblShipmentCost>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;
        }
        public static int GetNonDeletedShipmentCostCount()
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_SHIPMENTCOST_GET_NONDELETED_SHIPMENTCOST_COUNT);
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

        public static CustomCollection<TblShipmentCost> GetActiveShipmentCostPaged(string orderBy, int startRow, int pageSize)
        {
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_SHIPMENTCOST_GET_ACTIVE_SHIPMENTCOST_PAGED);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblShipmentCostCollectionFromReader);
            CustomCollection<TblShipmentCost> objCollection = ((CustomCollection<TblShipmentCost>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;
        }
        public static int GetActiveShipmentCostCount()
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_SHIPMENTCOST_GET_ACTIVE_SHIPMENTCOST_COUNT);
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

        public static CustomCollection<TblShipmentCost> GetNonDeletedShipmentCostByWeightRangePaged(Decimal weightRange, string orderBy, int startRow, int pageSize)
        {
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@weightRange", SqlDbType.Decimal, 9, ParameterDirection.Input, weightRange);
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_SHIPMENTCOST_GET_NONDELETED_SHIPMENTCOST_BY_WEIGHTRANGE_PAGED);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblShipmentCostCollectionFromReader);
            CustomCollection<TblShipmentCost> objCollection = ((CustomCollection<TblShipmentCost>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;

        }
        public static int GetNonDeletedShipmentCostByWeightRangeCount(Decimal weightRange)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@weightRange", SqlDbType.Decimal, 9, ParameterDirection.Input, weightRange);
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_SHIPMENTCOST_GET_NONDELETED_SHIPMENTCOST_BY_WEIGHTRANGE_COUNT);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

        public static CustomCollection<TblShipmentCost> GetAllShipmentCostByWeightRangePaged(Decimal weightRange, string orderBy, int startRow, int pageSize)
        {
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@weightRange", SqlDbType.Decimal, 9, ParameterDirection.Input, weightRange);
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRow);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, pageSize);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_SHIPMENTCOST_GET_ALL_SHIPMENTCOST_BY_WEIGHTRANGE_PAGED);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblShipmentCostCollectionFromReader);
            CustomCollection<TblShipmentCost> objCollection = ((CustomCollection<TblShipmentCost>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;

        }
        public static int GetAllShipmentCostByWeightRangeCount(Decimal weightRange)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@weightRange", SqlDbType.Decimal, 9, ParameterDirection.Input, weightRange);
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_SHIPMENTCOST_GET_ALL_SHIPMENTCOST_BY_WEIGHTRANGE_COUNT);
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

        public static TblShipmentCost GetTblShipmentCostByWeight(double productTotalWeight)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@Weight", SqlDbType.Decimal, 0, ParameterDirection.Input, productTotalWeight);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_TBL_SHIPMENTCOST_GET_NONDELETED_SHIPMENTCOST);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblShipmentCostCollectionFromReader);
            CustomCollection<TblShipmentCost> objCollection = ((CustomCollection<TblShipmentCost>)ExecuteReaderCmd(sqlCmd, test));

            if (objCollection.Count > 0)
                return objCollection[0];
            else
                return null;
        }

        private const string SP_TBL_SHIPMENTCOST_GET_ALL_SHIPMENTCOST_BY_WEIGHTRANGE_PAGED = "sp_TblShipmentCost_Get_All_ShipmentCost_By_WeightRange_Paged";
        private const string SP_TBL_SHIPMENTCOST_GET_ALL_SHIPMENTCOST_BY_WEIGHTRANGE_COUNT = "sp_TblShipmentCost_Get_All_ShipmentCost_By_WeightRange_Count";

        private const string SP_TBL_SHIPMENTCOST_GET_ACTIVE_SHIPMENTCOST_PAGED = "sp_TblShipmentCost_Get_Active_ShipmentCost_Paged";
        private const string SP_TBL_SHIPMENTCOST_GET_ACTIVE_SHIPMENTCOST_COUNT = "sp_TblShipmentCost_Get_Active_ShipmentCost_Count";

        private const string SP_TBL_SHIPMENTCOST_GET_NONDELETED_SHIPMENTCOST_PAGED = "sp_TblShipmentCost_Get_NonDelete_ShipmentCost_Paged";
        private const string SP_TBL_SHIPMENTCOST_GET_NONDELETED_SHIPMENTCOST_COUNT = "sp_TblShipmentCost_Get_NonDelete_ShipmentCost_Count";

        private const string SP_TBL_SHIPMENTCOST_GET_NONDELETED_SHIPMENTCOST_BY_WEIGHTRANGE_PAGED = "sp_TblShipmentCost_Get_NonDelete_ShipmentCost_By_WeightRange_Paged";
        private const string SP_TBL_SHIPMENTCOST_GET_NONDELETED_SHIPMENTCOST_BY_WEIGHTRANGE_COUNT = "sp_TblShipmentCost_Get_NonDelete_ShipmentCost_By_WeightRange_Count";
        private const string SP_TBL_SHIPMENTCOST_GET_NONDELETED_SHIPMENTCOST = "sp_TblShipmentCost_Get_NonDelete_ShipmentCost_By_WeightRange";
    }
}

